var userId = searchToObj(location.search).userId;
function searchToObj(str) {
  var newStr = str.substr(1);
  var strArr = newStr.split('&'); 
  var obj = {};
  for (var i = 0; i < strArr.length; i++) {
    var o = strArr[i].split('=');
    obj[o[0]] = o[1];
  }
  return obj;
}
console.log(userId)
function addcent1(nowStudents) {
    $('#ly_cent1').html('');
        var cent = `
            <div class="row">
                <div class="list-group col-lg-5 col-md-5 col-sm-12">
                    <ul>
                        <li class="list-group-item ly_div1">
                            <div class="ly_div1_box1">
                                <div class="ly_div1_box1-1">
                                    <img src="../../images/ly_images/微信图片_20220301113302.jpg" alt="">
                                </div>
                                <p>${nowStudents.name}</p>
                                <p>三好学生</p>
                            </div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">入学时间</div>
                            <div class="ly_w2">${nowStudents.Dates}</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">出生年月</div>
                            <div class="ly_w2">${nowStudents.years}</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">综合评分</div>
                            <div class="ly_w2">优秀</div>
                        </li>
                    </ul>
                    <ul>
                        <li class="list-group-item ly_div2">
                            <div>
                                <P class="ly_div2_box1">关于学生</P>
                                <p class="ly_div2_box2">
                                ${nowStudents.introduce}
                                </p>
                            </div>  
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">性别</div>
                            <div class="ly_w2">${nowStudents.gender}</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">教育</div>
                            <div class="ly_w2">高中在读</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">父母</div>
                            <div class="ly_w2">${nowStudents.parentname}</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">父母联系电话</div>
                            <div class="ly_w2">${nowStudents.parentphone}</div>
                        </li>
                        <li class="list-group-item ly_hei1">
                            <div class="ly_w1">联系地址</div>
                            <div class="ly_w2">${nowStudents.address}</div>
                        </li>
                        <li class="list-group-item ly_div3">
                            <div class="row">
                                <div class="ly_div3_box1 col-lg-4 col-md-5 col-sm-12">
                                    <p class="ly_div3_box1_p1"><span class="cor1">1111</span>小时</p>
                                    <p class="ly_div3_box1_p2">
                                        累计上课时长
                                    </p>
                                </div>
                                <div class="ly_div3_box2 col-lg-4 col-md-5 col-sm-12">
                                    <p class="ly_div3_box2_p1"><span class="cor1">222</span>项</p>
                                    <p class="ly_div3_box2_p2">
                                        累计获奖数量
                                    </p>
                                </div>
                                <div class="ly_div3_box3 col-lg-4 col-md-5 col-sm-12">
                                    <p class="ly_div3_box3_p1"><span class="cor1">89</span>分</p>
                                    <p class="ly_div3_box3_p2">
                                        综合平均分
                                    </p>
                                </div>
                            </div>   
                        </li>
                    </ul>
                </div>    
                <div class="list-group col-lg-7 col-md-7 col-sm-12 ly_right">
                    <ul>
                        <li class="list-group-item">
                            <div class="ly_right_div1">
                                <a href="javascript:;"><p class="ly_right_div1_1">学生获得奖项</p></a>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="ly_right_div2">
                                ${nowStudents. Awards}
                            </div>
                            <div class="ly_right_div3">
                                <p class="ly_right_div3_box1">爱好</p>
                                <div class="ly_right_div3_box2">
                                    <P>${nowStudents.hobby}</P>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div> 
            `    
    $('#ly_cent1').append(cent); 
}

initaddcent1()
function initaddcent1() {
    $.ajax({
        url: '/student/details',
        method: 'POST',
        data: {
            userId
        }
      })
        .done(function (res) {   
            // console.log(res.data)
            addcent1(res.data);
        })
        .fail(function (err) {
          console.log('请求失败：', err);
        });
}